package main

import "fmt"

//Address 地址结构体
type Address struct {
	Province string
	City     string
}

//User 用户结构体
type User struct {
	Name     string
	Gender   string
	*Address //指针类型匿名结构体
}

func main() {
	var user User
	//1、直接用&设置
	user = User{"chen", "man", &Address{"四川", "广安"}}
	fmt.Println(user)
	//2、用new出来的东西做地址：先分配空间
	user.Address = new(Address)
	user.City = "四川"
	user.Province = "广安"
	user.Name = "chen"
	user.Gender = "man"
	fmt.Println(user, *user.Address)
}
